﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using System.Web.Script.Services;
namespace JTicket.UI.Service
{
    /// <summary>
    /// Summary description for JT_ComanySvc
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    [GenerateScriptType(typeof(Model.C_CompanyInfo))]
    public class JT_ComanySvc : System.Web.Services.WebService
    {
        [WebMethod]
        public bool Exists(string ComanyCode)
        {
            return BLL.C_CompanyInfo.Exists(ComanyCode);
        }


        [WebMethod]
        public void Delete(string ComanyCode)
        {
            BLL.C_CompanyInfo.Delete(ComanyCode);
        }

        [WebMethod]
        public string Add(JTicket.Model.C_CompanyInfo model)
        {
            if (!BLL.C_CompanyInfo.Exists(model.ComanyCode))
            {
                BLL.C_CompanyInfo.Add(model);
                return "添加成功！";
            }
            else
                return "该企业编号已存在！";

        }

        [WebMethod]
        public void Deletes(string ComanyCodes)
        {
            string[] companycode = ComanyCodes.TrimEnd('|').Split('|');
            foreach (var code in companycode)
            {
                BLL.C_CompanyInfo.Delete(code);
            }
        }
        [WebMethod]
        public void Update(JTicket.Model.C_CompanyInfo model)
        {
            BLL.C_CompanyInfo.Update(model);
        }

        [WebMethod]
        public JTicket.Model.C_CompanyInfo Model(string CompanyCode)
        {
            BLL.C_CompanyInfo bllCompany = new BLL.C_CompanyInfo();
            if (BLL.C_CompanyInfo.Exists(CompanyCode))
                return bllCompany.GetModel(CompanyCode);
            else
                return null;
        }
    }
}
